package com.jnyoubo.autolxr;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
import com.blankj.utilcode.util.CacheDiskUtils;
import com.blankj.utilcode.util.EncryptUtils;

public class SqActivity extends AppCompatActivity implements View.OnClickListener {


    EditText incode;
    Button qrsq;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_sq);

        incode=findViewById(R.id.incode);
        qrsq=findViewById(R.id.qrsq);
        qrsq.setOnClickListener(this);


    }



    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.qrsq:
                sq();
                break;

        }
    }

    private void sq(){

        String code=incode.getText().toString().trim().toUpperCase();
        String jima=CacheDiskUtils.getInstance().getString("jiqima");
        String pwd="asdfghjkl@123456789";
        String md5= EncryptUtils.encryptMD5ToString(jima+pwd);

        if(!(md5).equals(code)){
            Toast.makeText(SqActivity.this, "授权码有误", Toast.LENGTH_SHORT).show();
        }else{
            CacheDiskUtils.getInstance().put("authorization",code);
            Toast.makeText(SqActivity.this, "授权成功", Toast.LENGTH_SHORT).show();
            finish();
        }
    }




}
